<include file="public@header" />
<style>
    div.qian {
        border-bottom: 1px dotted #777;
        padding: 10px
    }
    div.qian>div {
         margin: 3px 15px 0;
     }
    .card-body {
        position: relative;
        padding: 10px 15px;
        line-height: 24px;
    }
    body{padding-bottom:0!important}
    div.card-text{border-radius:8px;border:1px solid #888;}
    div.card-text:hover{border-color:#f30;cursor:pointer}
    div.mw{font-size:18px;color:#000;border-bottom:1px dotted #666}
    div.qfmp p{margin:8px 10px;font-size:16px;color:#333}
    mark{background-color:#adcb9d;padding:2px 3px}
    mark.red{background-color:#feb08e}
</style>
<div class="wrap js-check-wrap">
    <form class="form-horizontal result_form " action="{:url('')}" style="color: #000!important;">
        <div class="card-body">
        <fieldset>
            <div class="form-group" style="border-bottom:1px dashed;margin-bottom:20px;">
                <label class=" col-md-2 control-label " style="width: 25%">客户名称：{$result.buyer_name}</label>
                <label class="col-md-4 control-label " style="width: 35%">联系方式：{$result.buyer_phone}</label>
                <label class="col-md-2 control-label  "style="width: 25%">墓位编号：{$result.tomb_num}</label>

            </div>
            <div class="form-group" style="border-bottom:1px dashed;margin-bottom:20px;">
                <div class="qian">
                    <div>提交人{$restl.receptionist}<span style="margin-left:20px">{$pay_info.add_time|date='Y-m-d H:i:s'}</span></div>
                    <div  >应交<mark>{$pay_info.total_price}</mark>元，款项类型：{$rest_title}</div>
                    <div >
                        <div  >这笔合计应收
                            <mark>{$pay_info.total_price}</mark>元
                        </div>
                    </div>
                </div>
                <div class="form-group" style="float: right;margin-top: 15px;" >
                    <div class="col-lg-12" style=" ">
                        <label class="control-label"> </label>
                        <input type="hidden" name="pay_id"   value="{$pay_info.id}">
                        <input type="hidden" name="tomb_type"   value="1">
                        <input type="hidden" name="dtype" id="otype" value="4">
                        <input type="hidden" name="order_id" value="{$result.order_id|default=''}">
                        <input type="hidden" name="tomb_id" value="{$result.tomb_id|default=''}">
                        <input type="hidden" name="tomb_num" value="{$result.tomb_num|default=''}">
                        <input type="hidden" name="customer_id" value="{$result.customer_id|default=''}">
                        <input type="hidden" name="deposit_id" value="{$restl.deposit_id|default=''}">
<!--                        <div class="btn btn-primary" id="Print_statement">打印结算单</div>-->
                        <div class="btn btn-primary" id="settlement">结账</div>
                    </div>
                </div>
            </div>
        </fieldset>
        </div>
    </form>
    <script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
    <script type="text/javascript" src="__STATIC__/js/layer/layer.js"></script>
    <script>
        // 打印结算单
        $("#settlement").click(function(){
            $("#otype").val(2);
            // $.post($(".form-horizontal").attr('action'), $(".form-horizontal").serialize(), function(result){
            //     console.log(result)
                // if(result.code == 1){
                    layer.confirm("这笔款确定结清了吗？", {
                        icon: 3,
                        title: "提示", btn: ['确定', '没有']
                        , btn1: function () {
                            $.ajax({
                                type: "POST",
                                url: $(".form-horizontal").attr('action'),
                                data: $(".form-horizontal").serialize(),
                                dataType: "json",
                                success: function (r) {
                                    console.log(r)
                                    if (r.code == 1) { layer.alert("操作失败！", { icon: 5 }); }
                                    else {
                                        var L;
                                        if (r.cw == "l") { L = "&l=l"; } else { L = ""; }
                                        layer.confirm("操作成功！", {
                                            icon: 1, btn: ['打印收据', '关闭']
                                            , btn1: function () {
                                                location.reload();
                                                window.open("{:url('')}?mwid=" + r.data.mwid + "&fid=" + r.data.fid + "&depid=" + r.data.depid + L);
                                            },
                                            btn2: function () {
                                                parent.location.reload();
                                            }
                                        });
                                    }
                                }
                            });
                        }
                        , btn2: function () {
                            layer.closeAll();
                        }
                    }); 
        });
        // 结账
        $("#settlement").click(function(){
            $("#otype").val(1);
            $.post($(".form-horizontal").attr('.form-horizontal'), $("form").serialize(), function(result){
                console.log(result)
               /* if(result.code == 1){
                    window.location.href = result.url;
                } else {

                }*/
            }, 'json');
        });
    </script>
</div>